<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title></title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no" />
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<link rel="stylesheet" href="../../css/base.css" />
	<link rel="stylesheet" href="../../css/personal/set_zhifuPassword.css" />
	<script src="../../js/jquery-2.2.3.min.js"></script>
	<script type="text/javascript" src="../../js/rem.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<style>
		.setPassword,.setAgainPassword {
			border: 0;
			height: 100%;
			outline: none;
		}
	</style>
</head>

<body>
	<div class="header">
		<a onclick="javascript:history.go(-1)" href="javascript:0;"><img src="../../img/g_next.png" alt="" /></a>
		设置支付密码
	</div>
	<ul class="set_zhifupassword_main">
		<!-- <li class="set_zhifupassword_main_li">
			<span class="title">手机号</span>
			<input type="text" placeholder="请输入新的手机号" />
		</li> -->
		<!-- <li class="set_zhifupassword_main_li">
				<span class="title">验证码</span>
				<input class="YZM_txt" type="text" placeholder="请输入验证码" />
				<div class="getCode">
					获取验证码
				</div>
			</li> -->
		<li class="set_zhifupassword_main_li">
			<span class="title">支付密码</span>
			<input class="txt setPassword" type="password" placeholder="请设置6位数字密码" />
		</li>
		<li class="set_zhifupassword_main_li">
			<span class="title ">确认密码</span>
			<input class="txt setAgainPassword" type="password" placeholder="请再次确认支付密码" />
		</li>
	</ul>
	<input class="set_zhifupassword_btn" id="sad" type="button" value="确认" />
</body>
<script>
	var countdown = 60;

	function sendemail() {
		var obj = $(".getCode");
		settime(obj);

	}

	function settime(obj) { //发送验证码倒计时
		if (countdown == 0) {
			obj.attr('disabled', false);
			//obj.removeattr("disabled");
			obj.text("获取验证码");
			countdown = 60;
			return;
		} else {
			obj.attr('disabled', true);
			obj.text("重新发送(" + countdown + ")");
			countdown--;
		}
		setTimeout(function () {
			settime(obj)
		}, 1000)
	}
	$('.getCode').click(function () {
		sendemail();
	})

	$('#sad').on('click',function(){
		// console.log(1)
		var setRest = /^\d{6}$/;
		var setPassword = $('.setPassword').val();
		var setAgainPassword = $('.setAgainPassword').val();
		if (!setRest.test(setPassword)) {
			alert('密码必须为6位数字组成并且不能为空！')
			$('.setPassword').val('');
			$('.setAgainPassword').val('');
		} else if(setPassword==setAgainPassword){
			var aa = {
					'userid': localStorage.getItem('userId'),
					'newPayPassword': setPassword
				}
			$.ajax({
				type: 'get',
				url: SURL + '/api/xlsUser/setPayPassword',
				dataType: 'json',
				contentType:'applaction/json',
				data:aa,
				success: res => {
					if (res.status == 1){
						window.history.go(-1)
					}else{
						alert(res.msg)
					}
				}
			})
		}else{
			alert('两次输入密码不一致')
			$('.setAgainPassword').val('');
		}
	})
</script>

</html>
